<link rel="stylesheet" href="../addons/jy_exchange/css/common.css?v=2019">
<div class='fui-page fui-page-current'>
    <div class="fui-content">
        <div class="block-exchange">
            <div class="title">
                <p class="text">兑换中心</p>
                <p class="text2" style="display: none;">兑换码: {{pagedata.item.code}}</p>
                <p class="num">此兑换码已查询<span id="num">1</span>次</p>
            </div>
            <div class="input">
                <input placeholder="请输入兑换码" id="exchangeno" ng-model="pagedata.item.code"/>
            </div>
			<div class="btn btn-danger block" ng-click="pagedata.pay();" id="exchange">马上兑换</div>
            <div class="btn btn-default block" id="reset">返回重新输入兑换码</div>
            <!--<div class="list" style="margin-top:20px;">
                <div ng-if="pagedata.balance.id" class="item balance">
                    <div class="ico money"></div>
                    <div class="info">
                        <p class="t1">余额兑换</p>
                        <p class="t2">面值：{{pagedata.balance.balance}}元</p>
                    </div>
                    <div ng-click="access_json('jy_exchange/input//groupid='+pagedata.balance.id);" class="btn-exc btn btn-danger btn-sm" id="balance">兑换</div>
                </div>
                <div ng-if="pagedata.credit.id" class="item score">
                    <div class="ico credit"></div>
                    <div class="info">
                        <p class="t1">积分兑换</p>
                        <p class="t2">面值：{{pagedata.credit.score}}元</p>
                    </div>
                    <div ng-click="access_json('jy_exchange/input//groupid='+pagedata.credit.id);" class="btn-exc btn btn-danger btn-sm" id="score">兑换</div>
                </div>
                <div ng-if="pagedata.coupon.id" class="item coupon">
                    <div class="ico coupon"></div>
                    <div class="info">
                        <p class="t1">优惠券兑换</p>
                        <p class="t2">面值：{{pagedata.coupon.fee}}元</p>
                    </div>
                    <div ng-click="access_json('jy_exchange/input//groupid='+pagedata.coupon.id);" class="btn-exc btn btn-danger btn-sm" id="coupon">兑换</div>
                </div>
                <div ng-if="pagedata.red.id" class="item red">
                    <div class="ico redbag"></div>
                    <div class="info">
                        <p class="t1">红包兑换</p>
                        <p class="t2">面值：{{pagedata.red.red}}元</p>
                    </div>
                    <div ng-click="access_json('jy_exchange/input//groupid='+pagedata.red.id);" class="btn-exc btn btn-danger btn-sm" id="red">兑换</div>
                </div>
                <div ng-if="pagedata.goods.id" class="item goods">
                    <div class="ico goods"></div>
                    <div class="info">
                        <p class="t1">商品兑换</p>
                        <p class="t2">面值：{{pagedata.goods.price}}元</p>
                    </div>
                    <div ng-click="access_json('jy_exchange/input//groupid='+pagedata.goods.id);" class="btn-exc btn btn-danger btn-sm" id="goods">兑换</div>
                </div>
            </div>-->
        </div>

        <div ng-show="pagedata.rule" class="block-info">
            <div class="head">
                <div class="title">兑换中心</div>
            </div>
            <div class="info">
                <p><b>兑换规则</b></p>
                <p>{{pagedata.rule}}</p>
            </div>
        </div>

        <div class="alert-success-outer" style="display: none;">
            <div class="alert-success">
                <div class="text" id="status1">恭喜！兑换成功！</div>
                <div class="btn btn-warning">确定</div>
            </div>
        </div>

        <div class="alert-error-outer" style="display: none;">
            <div class="alert-error">
                <div class="text" id="status0">很遗憾！兑换码已失效！</div>
                <div class="btn btn-warning">知道了</div>
            </div>
        </div>
		<div class="fui-cell-group fui-cell-click" style="background:none;padding:0 2rem">
			<a class="fui-cell external changepwd" href="javascript:;" ng-click="access_json('jy_weishop/member.index/')">
				<div class="fui-cell-text" style="text-align: center;">返回会员中心</div>
			</a>
		</div>
    </div>
   <!-- 关注按钮 -->
	<div class="fe-guide" ng-if="pagedata.needfollow" style="display:block;z-index:890;">
		<div class="fe-guide-faceimg"><img ng-src="{{tomedia(pagedata.pluginset.logo) || '../core/resource/images/nopic.jpg'}}" /></div>
		<div class="fe-guide-sub" onclick="$('#followbar').modal();">立即关注</div>
		<div class="fe-guide-text">
			<p class="">{{pagedata.pluginset.followtitle ||'加关注,更多权限！'}}</br>{{pagedata.pluginset.followdesc ||'关注公众号，享专属服务'}}</p>
		</div>
	</div>
	<div id="followbar" class="modal fade" tabindex="-1" style="z-index:99999;display:none;position: absolute">
		<div class="modal-dialog" style="width:60%;left:20%">
			<div class="wap-qrcode-container">
				<p class="example1">{{pagedata.pluginset.title || '欢迎浏览'}}</p>
					<div class="wap-qrcode-image">
						<img ng-src="{{tomedia(pagedata.pluginset.ewm) || '../core/resource/images/nopic.jpg'}}"/>
					</div>
				<p class="example1">长按二维码关注</p>
				</div>
		</div>
	</div>
</div>
<script>
scope.pagedata.pay=function(){
    scope.post_json('jy_exchange/index/post/',scope.pagedata.item,function(res){
		if(res.id && res.payid){
			scope.pagedata.order_id=res.id;
			var success_url ='jy_exchange/index/'
			scope.tool.pay(res.payid,function(res){
					if(res.type=='success'){
						scope.message('支付成功！','success',success_url);
					}else{
						scope.message('支付失败！','success',success_url);
					}
			},'','',success_url,success_url);
		}else{
			scope.message(res,'success',success_url);
		}
	});
}
</script>
